1. Technical Field
The technology presented herein relates to orientation calculation apparatuses and programs for calculating an orientation of an input device, and more particularly, the present technology relates to an orientation calculation apparatus and program for calculating an orientation based on an output from an acceleration sensor included in an input device.
2. Description of the Background Art
Conventionally, there have been proposed techniques for calculating an orientation of an input device based on an output from an acceleration sensor included in an input device. For example, in Patent Document 1 (Japanese Laid-Open Patent Publication No. 2007-282787), an orientation is calculated based on a value obtained by smoothing an acceleration detected by an acceleration sensor within a predetermined period. In Patent Document 1, by smoothing a detected acceleration, components related to movement of the input device are removed from the detected acceleration, so that the detected acceleration only includes components related to gravitational acceleration. As a result, the direction of gravity can be accurately calculated based on the output from the acceleration sensor, making it possible to accurately calculate an orientation of the input device.
In the orientation calculation method described in Patent Document 1, a process for smoothing an acceleration detected within a predetermined period is performed. The smoothing process requires a plurality of acceleration values for a predetermined period in the past, and therefore the method described in Patent Document 1, which involves the smoothing process, has limited responsiveness as to orientation calculation.
Therefore, a feature of an example embodiment presented herein is to provide an orientation calculation apparatus and program capable of calculating with high responsiveness an orientation of an input device based on an acceleration.
The present embodiment has the following features to attain the above. Here, the reference numerals, the supplementary description and the like in the parentheses indicate a correspondence with the embodiment described below in order to aid in understanding the present embodiment and are not intended to limit, in any way, the scope of the present embodiment.
The present embodiment is directed to an orientation calculation apparatus (game apparatus 3) for calculating an orientation of an input device (8) including an acceleration sensor (37) and an angular rate sensor (gyroscope 55, 56) based on at least acceleration data (64) and angular rate data (63) acquired from the input device. The orientation calculation apparatus includes reflection rate setting means (CPU 10 performing step S3; hereinafter, only step numbers will be indicated), first orientation calculation means (S5), and second orientation calculation means (S6). The reflection rate setting means sets a reflection rate (s) representing a degree by which an acceleration (acceleration vector Va) indicated by the acceleration data is reflected in the orientation. The first orientation calculation means calculates the orientation of the input device based on the acceleration indicated by the acceleration data when the reflection rate is equal to or greater than a predetermined first threshold (where the reflection rate s=1). The second orientation calculation means calculates the orientation of the input device based on an angular rate (ω) indicated by the angular rate data when the reflection rate is less than a predetermined second threshold equal to or less than the first threshold (where the reflection rate s=0).
According to the above configuration, when the reflection rate is high (equal to or higher than the first threshold), the orientation of the input device is calculated based on the acceleration, and when the reflection rate is low (less than the second threshold), the orientation of the input device is calculated based on the angular rate. When it is not appropriate to calculate the orientation based on the acceleration, the orientation is calculated based on the angular rate, and therefore orientation calculation is possible even when the acceleration-based orientation calculation is not performed. Accordingly, it is possible to prevent deterioration in responsiveness due to no orientation being calculated during a period in which the acceleration-based orientation calculation is not performed, making it possible to calculate the orientation of the input device with high responsiveness.
Also, the second threshold may be less than the first threshold. In this case, the orientation calculation apparatus further includes third orientation calculation means (S7 shown in FIG. 10). The third orientation calculation means calculates the orientation of the input device so as to fall between the orientations calculated by the first and second orientation calculation means when the reflection rate is less than the first threshold and equal to or greater than the second threshold.
According to the above configuration, when the reflection rate is moderate (less than the first threshold and equal to or greater than the second threshold), the third orientation calculation means calculates the orientation considering both the first orientation based on the acceleration and the second orientation based on the angular rate. Here, during a transitional period in which the input device transitions between states where the reflection rate is high and where the reflection rate is low, there is a possibility that the orientation to be calculated might change suddenly due to a change of the orientation calculation method. On the other hand, according to the above configuration, the third orientation calculation means calculates the orientation during the transitional period, and therefore it is possible to prevent the orientation from changing suddenly due to any change of the orientation calculation method. Thus, it is possible to prevent the user from feeling unnatural about any sudden change in orientation, making it possible to improve operability of the input device.
Also, the third orientation calculation means may calculate the orientation of the input device as a weighted average of the orientations calculated by the first and second orientation calculation means, the weighted average being obtained based on a weight corresponding to the reflection rate (equation (5)).
According to the above configuration, the third orientation calculation means calculates the orientation of the input device using an acceleration-based orientation and an angular rate-based orientation at a ratio corresponding to the reflection rate. Accordingly, the orientation can be accurately calculated even during a transitional period in which the input device transitions between states where the reflection rate is high and where the reflection rate is low.
Also, the first threshold and the second threshold may be equal. In this case, the first orientation calculation means calculates the orientation of the input device when the reflection rate is equal to or greater than the first threshold. The second orientation calculation means calculates the orientation of the input device when the reflection rate is less than the first threshold (FIG. 11).
According to the above configuration, the orientation of the input device is calculated without fail by the first or second orientation calculation means regardless of the value of the reflection rate. That is, the orientation of the input device can always be calculated, and therefore it is possible to further improve responsiveness as to orientation calculation. Furthermore, when compared to the case where the third orientation calculation means is provided, the orientation calculation process can be simplified, resulting in increased processing speed.
Also, the orientation calculation apparatus may further include fourth orientation calculation means (step S7 shown in FIG. 12). The fourth orientation calculation means calculates the orientation of the input device so as to fall between the orientations calculated by the first and second orientation calculation means when the reflection rate is less than the first threshold and equal to or greater than the second threshold and is rising. The second orientation calculation means calculates the orientation of the input device based on the angular rate indicated by the angular rate data when the reflection rate is less than the second threshold or when the reflection rate is less than the first threshold and is falling.
According to the above configuration, when the reflection rate is moderate (less than the first threshold and equal to or greater than the second threshold) and is rising, the third orientation calculation means calculates the orientation considering both the first orientation based on the acceleration and the second orientation based on the angular rate. Here, during a transitional period in which the input device transitions from the state where the reflection rate is high to the state where the reflection rate is low, there is a possibility that the orientation might change suddenly due to a change of the orientation calculation method. On the other hand, according to the above configuration, the third orientation calculation means calculates the orientation during the transitional period, and therefore it is possible to prevent the orientation from changing suddenly due to any change of the orientation calculation method. Thus, it is possible to prevent the user from feeling unnatural about any sudden change in orientation, making it possible to improve operability of the input device.
Also, the reflection rate setting means may calculate the reflection rate based on the acceleration indicated by the acceleration data (equation (1)).
According to the above configuration, by using the acceleration data, the reflection rate can be readily calculated. Also, by referencing the acceleration data, the orientation calculation apparatus can estimate the degree of motion of the input device (whether at rest or in motion), and furthermore, the orientation calculation apparatus can determine the dependability for the acceleration indicated by the acceleration data (the degree representing whether or not the acceleration reliably represents the direction of gravity). In this manner, according to the above configuration, the dependability can be represented by the reflection rate, and therefore whether to calculate the orientation based on the acceleration or the angular rate can be determined in accordance with the dependability. Thus, it is possible to accurately calculate the orientation of the input device.
Also, the reflection rate setting means may calculate the reflection rate so as to be higher the lower the amount of change for the acceleration indicated by the acceleration data (equation (1)).
According to the above configuration, the reflection rate is calculated in accordance with the amount of change for the acceleration. By referencing the amount of change for the acceleration, the degree of motion of the input device can be accurately estimated, thereby accurately determining the dependability for the acceleration. Accordingly, by calculating the reflection rate in accordance with the amount of change for the acceleration, it becomes possible to appropriately set the reflection rate and thereby to accurately calculate the orientation of the input device.
Also, the reflection rate setting means may calculate the reflection rate so as to be higher the closer the magnitude of the acceleration indicated by the acceleration data is to the magnitude of a gravitational acceleration.
According to the above configuration, the reflection rate is calculated in accordance with the difference in magnitude between the acceleration and the gravitational acceleration. By referencing the difference in magnitude, the degree of motion of the input device can be accurately estimated, thereby determining the dependability for the acceleration. Accordingly, by calculating the reflection rate in accordance with the difference in magnitude, it becomes possible to appropriately set the reflection rate and thereby to accurately calculate the orientation of the input device.
Also, the reflection rate setting means may repeatedly calculate the reflection rate, and may correct the reflection rate so as to fall between a currently calculated reflection rate and a previously calculated reflection rate when the currently calculated reflection rate is higher than the previously calculated reflection rate (equation (2)).
According to the above configuration, when the reflection rate may rise, the increment of the reflection rate can be minimized by correction. Here, in some cases, the reflection rate calculated from the acceleration might temporarily rise while the input device 8 is being moved. In such a case, it is highly likely that in fact the acceleration does not accurately represent the direction of gravity, and therefore the reflection rate should be calculated as a lower value. On the other hand, according to the above configuration, when the reflection rate may temporarily rise, the reflection rate can be inhibited from rising by correction, and can be kept low. Thus, according to the above configuration, the reflection rate can be more accurately calculated to represent the dependability, making it possible to accurately calculate the orientation of the input device.
Also, the reflection rate setting means may determine a degree of motion of the input device based on operation data acquired from the input device, and may set the reflection rate so as to be lower the more vigorously the input device is moved.
According to the above configuration, the reflection rate is calculated to represent the degree of motion of the input device. As described above, the dependability for the acceleration indicated by the acceleration data can be determined based on the degree of motion of the input device. Thus, according to the above configuration, it is possible to appropriately set the reflection rate to represent the dependability, making it possible to accurately calculate the orientation of the input device.
Also, the angular rate sensor may be detachable from the input device. In this case, the reflection rate setting means determines whether or not the angular rate sensor is attached to the input device based on operation data acquired from the input device (S21), and sets the reflection rate in accordance with the determination result (S3 and S22 shown in FIG. 14).
According to the above configuration, the reflection rate is set to a different value depending on whether or not the input device has the angular rate sensor attached thereto. As a result, when the orientation calculation apparatus has no angular rate sensor attached thereto, the first orientation calculation means calculates the orientation based on the acceleration, and when the angular rate sensor is attached, the first and second orientation calculation means can be appropriately used for separate orientation calculations. Thus, the orientation calculation apparatus can address both cases where the angular rate sensor is attached or not attached.
Also, the first orientation calculation means may repeatedly calculate the orientation of the input device, and may calculate an orientation corresponding to a direction of gravity calculated as a weighted average of a direction of gravity corresponding to a previously calculated orientation and a direction of the acceleration, the weighted average being obtained based on a weight corresponding to the reflection rate (equation (3)).
According to the above configuration, the first orientation calculation means calculates the orientation of the input device considering the reflection rate, and therefore it is possible to more accurately calculate the orientation. Note that in the above configuration, if the reflection rate falls, the orientation becomes invariable, so that the orientation cannot almost be calculated. However, in the present embodiment, when the reflection rate is low, the orientation is calculated based on the angular rate, and therefore responsiveness as to orientation calculation does not deteriorate due to no orientation being calculated. In this manner, the present invention is effective especially when the orientation of the input device is calculated considering the reflection rate as in the above configuration.
Also, the present embodiment may be embodied as a computer-readable storage medium having stored therein an orientation calculation program (61) for causing a computer of an information processing apparatus to function as the respective means described above.
According to the present embodiment, when the acceleration-based orientation calculation is not performed, the angular rate-based orientation calculation is performed, thereby preventing responsiveness as to orientation calculation from deteriorating due to no orientation calculation being performed, so that the orientation of the input device can be calculated with high responsiveness.
These and other features, aspects and advantages of the present embodiment will become more apparent from the following detailed description of the present embodiment when taken in conjunction with the accompanying drawings.